package com.example.service.impl;

import com.example.entity.Customer;
import com.example.entity.Foodtable;
import com.example.entity.Menu;
import com.example.entity.PageBean;
import com.example.mapper.FoodtableMapper;
import com.example.mapper.MenuMapper;
import com.example.service.FoodtableService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class FoodtableServiceImpl implements FoodtableService {
    @Autowired
    private FoodtableMapper foodtableMapper;

    @Override
    public PageBean page(Integer page, Integer pageSize, String tableCondition) {
        PageHelper.startPage(page,pageSize);
        List<Foodtable> pageList=foodtableMapper.selectByPage(tableCondition);
        log.info("分页查询...");
        Page<Foodtable> p=(Page<Foodtable>) pageList;
        PageBean pageBean=new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }

    @Override
    public Foodtable findBytablecondition(String tablecondition) {
        Foodtable foodtable = foodtableMapper.findBytablecondition(tablecondition);
        return foodtable;
    }
    @Override
    public void updata(Foodtable foodtable) {
        foodtableMapper.updata(foodtable);
    }
    @Override
    public void add(Foodtable foodtable) {
        foodtableMapper.insert(foodtable);
    }
    @Override
    public void delete(String table_id) {
        foodtableMapper.delete(table_id);
    }
}
